import request from '@/utils/Request.js'
import {getLocalStroage} from "@/utils/LocalStroageUtil";

/**
 * 加载我分享的连接
 * @param data
 */
export const loadFileShareLinkApi = (data) => {
    return request.get("/share-file/search-all-link", {
        params: {
            ownerId: getLocalStroage().userId,
            current: data.current,
            size: data.size,
        }
    })
}

/**
 * 创建共享链接
 * @param data 包含文件ID、过期时间、提取码等参数
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const createNewFileShareLinkApi = (data) => {
    return request.post("/share-file/create-new-file-share-link", {
        ...data,
        ownerId: getLocalStroage().userId // 从本地存储获取当前用户ID
    })
}

/**
 * 删除共享链接
 * @param fileShareLinkId 共享链接ID
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deleteFileShareLinkApi = (fileShareLinkId) => {
    return request.delete("/share-file/delete-file-share-link", {
        params: {
            fileShareLinkId: fileShareLinkId
        }
    })
}